package httpclient;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.Socket;

public class HttpGetImpl { 
	
	public static void main(String[] args) throws Exception{
		InetAddress inet = InetAddress.getByName("www.baidu.com");
		
		Socket socket = new Socket("119.75.218.45", 80);
		StringBuilder sb = new StringBuilder();
		sb.append("GET /s?wd=111 HTTP/1.1" + "\r\n");
	    sb.append("Host: www.baidu.com" + "\r\n");
	    sb.append("\r\n");
		


		OutputStream os = socket.getOutputStream();
	    os.write(sb.toString().getBytes());
	    InputStream is =  socket.getInputStream();
	    BufferedReader br = new BufferedReader(new InputStreamReader(is));
	    String s;
	    while( (s=br.readLine()) != null) {
	    	System.out.print(s);
	    	System.out.println();
	    }

	    socket.close();
	    }

}
